interface AuthProvider {
    isAuthenticated: boolean;
    username: null | string;

    signin(username: string): Promise<void>;

    signout(): Promise<void>;
}

/**
 * This represents some generic auth provider API, like Firebase.
 */
export const fakeAuthProvider: AuthProvider = {
    isAuthenticated: false,
    username: null,
    async signin(username: string) {
        await new Promise((r) => setTimeout(r, 500)); // fake delay
        if (username === '123') {
            fakeAuthProvider.isAuthenticated = true;
            fakeAuthProvider.username = username;
        } else {
            throw Error
        }
    },
    async signout() {
        await new Promise((r) => setTimeout(r, 500)); // fake delay
        fakeAuthProvider.isAuthenticated = false;
        fakeAuthProvider.username = "";
    },
};
